var isSubmit = 0;// 0 可以提交，1 不可提交

function editPic(imgSort, isadd) {
    sessionStorage.setItem("isadd", isadd);
    sessionStorage.setItem("imgSort", imgSort);
    sessionStorage.setItem("category_ids", oneCategoryId + "," + twoCategoryId + "," + threeCategoryId);
    layer_show("修改图片", "spuPic.html", "1000", "800","100","200");
}
function addPic(imgSort, isadd) {
    sessionStorage.setItem("isadd", isadd);
    sessionStorage.setItem("imgSort", imgSort);
    sessionStorage.setItem("category_ids", oneCategoryId + "," + twoCategoryId + "," + threeCategoryId);
    layer_show("添加图片", "spuPic.html", "1000", "800","100","200");
}
// 删除图片
function deletePic(imgSort) {
    var popId = layer.confirm('确认要删除吗？',function(index){
        $(".addSpuImgbox").css({
            display:"block"
        })
        var getSpuImgCache = sessionStorage.getItem("spuImgCache");
        var spuInfoImg = JSON.parse(getSpuImgCache);
        var spuInfoImgArr = Object.keys(spuInfoImg);
        if(sessionStorage.getItem("spuImgCache")){
            var spuImgCache = JSON.parse(sessionStorage.getItem("spuImgCache"));
            if(imgSort == 1){
                if(spuImgCache.img2){
                    spuImgCache.img2.imgSort = 1;
                    spuImgCache.img1 = spuImgCache.img2;
                }
                if(spuImgCache.img3){
                    spuImgCache.img3.imgSort = 2;
                    spuImgCache.img2 = spuImgCache.img3;
                }
                if(spuImgCache.img4){
                    spuImgCache.img4.imgSort = 3;
                    spuImgCache.img3 = spuImgCache.img4;
                }
                if(spuImgCache.img5){
                    spuImgCache.img5.imgSort = 4;
                    spuImgCache.img4 = spuImgCache.img5;
                }
                switch (spuInfoImgArr.length){
                    case 1:
                        delete spuImgCache.img1;
                        console.log("-1")
                        break;
                    case 2:
                        delete spuImgCache.img2;
                        console.log("-2")
                        break;
                    case 3:
                        delete spuImgCache.img3;
                        console.log("-3")
                        break;
                    case 4:
                        delete spuImgCache.img4;
                        console.log("-4")
                        break;
                    case 5:
                        delete spuImgCache.img5;
                        console.log("-5")
                        break;
                }

            }else if(imgSort == 2){
                if(spuImgCache.img3){
                    spuImgCache.img3.imgSort = 2;
                    spuImgCache.img2 = spuImgCache.img3;
                }
                if(spuImgCache.img4){
                    spuImgCache.img4.imgSort = 3;
                    spuImgCache.img3 = spuImgCache.img4;
                }
                if(spuImgCache.img5){
                    spuImgCache.img5.imgSort = 4;
                    spuImgCache.img4 = spuImgCache.img5;
                }
                switch (spuInfoImgArr.length){
                    case 1:
                        delete spuImgCache.img1;
                        console.log("-1")
                        break;
                    case 2:
                        delete spuImgCache.img2;
                        console.log("-2")
                        break;
                    case 3:
                        delete spuImgCache.img3;
                        console.log("-3")
                        break;
                    case 4:
                        delete spuImgCache.img4;
                        console.log("-4")
                        break;
                    case 5:
                        delete spuImgCache.img5;
                        console.log("-5")
                        break;
                }
            }else if(imgSort == 3){
                if(spuImgCache.img4){
                    spuImgCache.img4.imgSort = 3;
                    spuImgCache.img3 = spuImgCache.img4;
                }
                if(spuImgCache.img5){
                    spuImgCache.img5.imgSort = 4;
                    spuImgCache.img4 = spuImgCache.img5;
                }
                switch (spuInfoImgArr.length){
                    case 1:
                        delete spuImgCache.img1;
                        console.log("-1")
                        break;
                    case 2:
                        delete spuImgCache.img2;
                        console.log("-2")
                        break;
                    case 3:
                        delete spuImgCache.img3;
                        console.log("-3")
                        break;
                    case 4:
                        delete spuImgCache.img4;
                        console.log("-4")
                        break;
                    case 5:
                        delete spuImgCache.img5;
                        console.log("-5")
                        break;
                }
            }else if(imgSort == 4){
                if(spuImgCache.img5){
                    spuImgCache.img5.imgSort = 4;
                    spuImgCache.img4 = spuImgCache.img5;
                }
                switch (spuInfoImgArr.length){
                    case 1:
                        delete spuImgCache.img1;
                        console.log("-1")
                        break;
                    case 2:
                        delete spuImgCache.img2;
                        console.log("-2")
                        break;
                    case 3:
                        delete spuImgCache.img3;
                        console.log("-3")
                        break;
                    case 4:
                        delete spuImgCache.img4;
                        console.log("-4")
                        break;
                    case 5:
                        delete spuImgCache.img5;
                        console.log("-5")
                        break;
                }
            }else if(imgSort == 5){
                delete spuImgCache.img5;
            }
            sessionStorage.setItem("spuImgCache",JSON.stringify(spuImgCache));
        }
        //var index = parent.layer.getFrameIndex(popId);
        layer.close(popId);
        addSpuPic();
    });
}
//渲染图片渲染函数
function addSpuPic() {
    $(".imgTable .imgboxUl").html("");
    if(sessionStorage.getItem("spuImgCache")){
        var getSpuImgCache = sessionStorage.getItem("spuImgCache");
        var spuInfoImg = JSON.parse(getSpuImgCache);
        for(item in spuInfoImg) {
            if(item.endWith("1")){
                $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg1" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId1" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl1" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox1" class="pt-10 updataBtn"><a onclick="editPic(1, false)" class="pd-20">修改</a><a onclick="deletePic(1)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 1)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort1" name="imgSort" style="width:40px"></div></div>')
            }if(item.endWith("2")){
                $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg2" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId2" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl2" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox2" class="pt-10 updataBtn"><a onclick="editPic(2, false)" class="pd-20">修改</a><a onclick="deletePic(2)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 2)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort2" name="imgSort" style="width:40px"></div></div>')
            }if(item.endWith("3")){
                $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg3" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId3" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl3" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox3" class="pt-10 updataBtn"><a onclick="editPic(3, false)" class="pd-20">修改</a><a onclick="deletePic(3)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 3)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort3" name="imgSort" style="width:40px"></div></div>')
            }if(item.endWith("4")){
                $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg4" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId4" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl4" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox4" class="pt-10 updataBtn"><a onclick="editPic(4, false)" class="pd-20">修改</a><a onclick="deletePic(4)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 4)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort4" name="imgSort" style="width:40px"></div></div>')
            }if(item.endWith("5")){
                $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg5" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId5" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl5" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox5" class="pt-10 updataBtn"><a onclick="editPic(5, false)" class="pd-20">修改</a><a onclick="deletePic(5)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 5)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort5" name="imgSort" style="width:40px"></div></div>');
                $(".addSpuImgbox").css({
                    display:"none"
                })
            }
        }
    }
}

function isNull () {
    if ($("#goodsName").val() == "") {
        console.log(111);
        $("#goodsName").css({
            border: "1px red solid"
        });
        $(".errorMsg").css({
            display:"inline"
        });
    }else{
        $("#goodsName").css({
            border: "1px #ddd solid"
        });
        $(".errorMsg").css({
            display:"none"
        });
        sessionStorage.setItem("name", $("#goodsName").val());
    }
}

function nameAdd() {
    var aliasInp = document.querySelectorAll(".aliasInp")
    console.log(aliasInp)
    if(aliasInp.length<10){
        $("#inpBox").append('<div class="formControls col-sm-9 f-l aliasInp"><input type="text" class="input-text radius f-l another_name" value="" name="another_name" style="width: 85%"><a onclick="nameDelete(this)" class="ml-20 f-l">删除</a></div>');
    }
}

/*删除别名输入框*/
function nameDelete(nameBox) {
    console.log(nameBox.parentElement);
    $(nameBox.parentElement).remove()
}

function attributeAdds() {
    if (threeCategoryId == "") {
        $.Huimodalalert("请选择所属分类", 2000);
        return false;
    }
    $(".attributeInp").css({display: 'inline'});
    /*$("#attributeBoxs").append('<div class="formControls col-sm-9 f-l attributeInp">' +
        '<span class="select-box size-M radius col-xs-8 ml-10" style="width: 35%">' +
        '<select class="select" id="attributeType" size="1">' +
        '<option value="-1" selected>---请选择---</option>' +
        '<option value="0">销售属性</option>' +
        '<option value="1">商品描述属性</option>' +
        '</select>' +
        '</span>&nbsp;&nbsp;&nbsp;&nbsp;' +
        '<span>' +
        '<input type="text" class="input-text radius f-l tuansName" onfocus="selectAttribute()" name="moli" placeholder="" oninput="selectAttribute()" style="width: 30%; margin-left: 15px;" autocomplete="off">' +
        '<ul class="relation radius guanlian tuans">' +
        '<li>无数据</li>' +
        '</ul>' +
        '</span>' +
        '<a href="#" onclick="nameDelete(this)" class="ml-20 f-l">删除</a>' +
        '</div>');*/
}

//运营经理获取光标
$("#tuansName").focus(function () {
    console.log('出现');
    $("#tuans").show();
});
$(document).bind("click", function (e) {
    //id为menu的是菜单，id为open的是打开菜单的按钮
    if ($(e.target).closest("#tuans").length == 0 && $(e.target).closest("#tuansName").length == 0) {
        //点击id为menu之外且id不是不是open，则触发
        $("#tuans").hide();
    }
});

function selectAttribute() {
    $.ajax({
        url: root.goodsInter.goods_listAttribute,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: "json",
        data: {
            category_id: threeCategoryId,
            attribute_type: $("#attributeType").val()
        },
        success: function (data) {
            if (data.errorCode == 0) {
                console.log(data.data);

                if (data.data == "") {
                    $("#tuans").html("<li>无数据</li> ");
                } else {
                    var obj = data.data;
                    var optionstring = "";
                    for (var i = 0; i < obj.length; i++) {
                        optionstring += "<li onclick='attCodeFun(" + obj[i].attribute_id + ",\"" + obj[i].attribute_name + "\")'>" + obj[i].attribute_name + "</li>";
                    }
                    $("#tuans").html(optionstring);
                }
            }
        }
    });
}

function attCodeFun(id, name) {
    console.log('id：' + id + '，name：' + name);
    $("#tuansName").val(name);
    sessionStorage.setItem("attrId", id);
    sessionStorage.setItem("attrName", name);
    $("#tuans").hide();
}

function attrDelete() {
    $(".attributeInp").css({display: 'none'});
    sessionStorage.removeItem("attrId");
    sessionStorage.removeItem("attrName");
    $("#attributeType").val(-1);
    $("#tuansName").val('');
}

/*---------------------------------选择品牌开始-------------------------------*/
function selectBrand() {
    $("#selectInp").css({
        display:"block"
    });
}
/*品牌选择*/
function myFunction(){
    $.ajax({
        url: root.goodsInter.goods_getListBrand,//root.goodsInter.goods_updateSpuDetail,
        cache: false,  //禁用缓存
        type: "POST",
        data: {
            brandName: $("#username").val()
        },
        success: function (data) {
            console.log(data)
            if(data.userName !=""){
                var jsonObj =data.data;
                if(jsonObj==""){
                    $("#tuan").html("<li>无数据</li> ");
                }else {
                    console.log(jsonObj)
                    var optionstring = "";
                    for (var  i= 0; i < jsonObj.length; i++) {
                        optionstring += "<li onclick='addCodeFun(" + jsonObj[i].brandId + ",\"" + jsonObj[i].brandName + "\")'>" + jsonObj[i].brandName + "</li>";
                    }
                    $("#tuan").html(optionstring);
                }
            }else{
                $("#tuan").html("<li>无数据</li> ");
            }
        }
    });
}
//运营经理获取光标
$("#username").focus(function () {
    $("#tuan").show()
});
$(document).bind("click", function (e) {
    //id为menu的是菜单，id为open的是打开菜单的按钮
    if ($(e.target).closest("#tuan").length == 0 && $(e.target).closest("#username").length == 0) {
        //点击id为menu之外且id不是不是open，则触发
        $("#tuan").hide()
    }
});
var brandName = "";
var brandId = "";
function addCodeFun(id,brand_name) {
    $("#tuan").hide();
    $("#username").val(brand_name);
    brandName = brand_name;
    brandId = id;
}
function brand_sure() {
    sessionStorage.setItem("brand_name",brandName);
    sessionStorage.setItem("brand_id",brandId);
    $("#selectInp").css({
        display:"none"
    });
    addBrandName();
}
function brand_cancel() {
    sessionStorage.removeItem("brand_name");
    sessionStorage.removeItem("brand_id");
    $("#selectInp").css({
        display:"none"
    });
}
//渲染品牌名称
function addBrandName() {
    if(sessionStorage.getItem("brand_name")){
        $("#brandName").html(sessionStorage.getItem("brand_name"));
        $("#brandId").html(sessionStorage.getItem("brand_id"));
    }
}
/*-----------------------------选择品牌结束--------------------------------*/
/*-----------------------------选择品类开始--------------------------------*/
function goods_listCategory(categoryLevel) {
    var categoryName = $("#class1").val();
    var user_data = {
        categoryLevel: categoryLevel,
        categoryName: $("#class1").val(),
    }
    var succCallBack = function (data, status, response) {
        console.log(data)
        if (data.errorCode == "0") {
            if (data.data == null) {
                classStr = "<li>无数据</li>"
                $("#classUl1").html(classStr);
            } else {
                var classStr = "";
                for (var i = 0; i < data.data.length; i++) {
                    classStr += "<li onclick='nextClass(" + data.data[i].category_id + "," + data.data[i].category_level + ",\"" + data.data[i].category_name + "\")'>" + data.data[i].category_name + "</li>"
                }
                $("#classUl1").html(classStr);
            }
        }
    }
    web.doAjax(root.goodsInter.categoryByParam, 'post', user_data, succCallBack);
}
//获取光标
$("#class1").focus(function () {
    $("#classUl1").show();
    goods_listCategory(1, 1);
});
$(document).bind("click", function (e) {
    //id为menu的是菜单，id为open的是打开菜单的按钮
    if ($(e.target).closest("#classUl1").length == 0 && $(e.target).closest("#class1").length == 0) {
        //点击id为menu之外且id不是不是open，则触发
        $("#classUl1").hide()
    }
});
var oneCategoryId = "";
var twoCategoryId = "";
var threeCategoryId = "";
// 2,3,4级的模糊查询
function getNext_input(level, category_id) {
    if(level == 2){
        oneCategoryId = category_id;
    }else if(level == 3){
        twoCategoryId = category_id;
    }else if(level == 4){
        threeCategoryId = category_id;
    }
    if (level<4){
        $("#class" + level + "")[0].oninput = function () {
            console.log(111)
            goods_listCategory(level, level, category_id);
        }
        //获取光标
        $("#class" + level + "").focus(function () {
            $("#classUl" + level + "").show();
            goods_listCategory(level, level, category_id);
        });
        $(document).bind("click", function (e) {
            //id为menu的是菜单，id为open的是打开菜单的按钮
            if ($(e.target).closest("#classUl" + level + "").length == 0 && $(e.target).closest("#class" + level + "").length == 0) {
                //点击id为menu之外且id不是不是open，则触发
                $("#classUl" + level + "").hide()
            }
        });
    }
    var categoryIds = oneCategoryId + "," +twoCategoryId + "," + threeCategoryId;
    sessionStorage.setItem("category_ids", categoryIds);
}
function nextClass(category_id, level, category_name) {
    $("#class" + level + "").val(category_name)
    var user_data = {
        parentCateId: category_id
    }
    var succCallBack = function (data, status, response) {
        console.log(data)
        if (data.errorCode == "0") {
            if (data.data == null) {
                classStr = "<li>无数据</li>";
            } else {
                var classStr = "";
                for (var i = 0; i < data.data.length; i++) {
                    classStr += "<li onclick='nextClass(" + data.data[i].category_id + "," + data.data[i].category_level + ",\"" + data.data[i].category_name + "\")'>" + data.data[i].category_name + "</li>"
                }
            }
            if(data.data[0] == undefined){
                classValue = category_id;
                var nextLevel = level+1;
                $("#classUl" + nextLevel + "").html(classStr);
                $("#classUl" + level + "").hide();
            }else {
                var nextLevel = data.data[0].category_level;
                $("#classUl" + nextLevel + "").html(classStr);
                $("#classUl" + nextLevel + "").show();
                $("#classUl" + level + "").hide()
            }
        }
    }
    getNext_input(level + 1, category_id);
    web.doAjax(root.goodsInter.categoryByParam, 'post', user_data, succCallBack);
}
/*-----------------------------选择品类结束--------------------------------*/
function checkRepeat(el, id) {
    isSubmit = 0;
    console.log(el.value);

    $(el).removeClass("error")
    if (el.value < 1 || el.value > 5) {
        isSubmit = 1;
        $.Huimodalalert("输入范围有误", 2000);
        console.log('输入范围有误')
        // $(el).addClass("error")
    }
    var imgSorts = document.getElementsByName('imgSort');
    for (var i = 0; i < imgSorts.length; i++) {
        if (i != (id-1)) {
            var obj = imgSorts[i];
            console.log(obj.value)
            if (Number(el.value) == Number(obj.value)) {
                // $(el).addClass("error")
                isSubmit = 1;
                console.log('数字重复')
                $.Huimodalalert("数字重复", 2000);
            }
        }

    }
    console.log(isSubmit);
}

function makeSure() {
    if (isSubmit != 0) {
        $.Huimodalalert("排序输入有误", 2000);
        return false;
    }
    if ($("#goodsName").val() == "") {
        $("#goodsName").css({
            border: "1px red solid"
        });
        $(".errorMsg").css({
            display:"inline"
        });
    }else if($("#brandName").html() == ""){
        $(".brandErrorMsg").css({
            display:"inline"
        });
    }else if ($("#subtitile").val().length > 100){
        $.Huimodalalert('商品副标题超出字符限制',2000);
        $("#subtitile").css({
            border: "1px red solid"
        });
        $(".subtitileErrorMsg").css({
            display:"inline"
        });
    } else{
        $("#subtitile").css({
            border: "1px #ddd solid"
        });
        $("#goodsName").css({
            border: "1px #ddd solid"
        });
        $(".subtitileErrorMsg").css({
            display:"none"
        });
        $(".errorMsg").css({
            display:"none"
        });
        $(".brandErrorMsg").css({
            display:"none"
        });
        var spuResult = JSON.parse(sessionStorage.getItem("spuInfo"));

        /*if(sessionStorage.getItem("attrObjCanch")){
            var attrObjCanch = JSON.parse(sessionStorage.getItem("attrObjCanch"));
            var  attValList = []
            for(var i=0;i<attrObjCanch.length;i++){
                attValList.push({"attributeId": attrObjCanch[i].attribute_id, "attriValueIds": []})
                for(var j=0;j<attrObjCanch[i].value.length;j++){
                    attValList[i].attriValueIds.push(attrObjCanch[i].value[j].attri_value_id);
                }
            }
        }else {
            var attrObjCanch = spuResult.attribute;
            var  attValList = []
            for(var i=0;i<attrObjCanch.length;i++){
                attValList.push({"attributeId": attrObjCanch[i].attribute_id, "attriValueIds": []})
                for(var j=0;j<attrObjCanch[i].value.length;j++){
                    attValList[i].attriValueIds.push(attrObjCanch[i].value[j].attri_value_id);
                }
            }
        }*/

        var spuImgs = [];
        if($("#spuImg1").children().length != 0){



            spuImgs.push( {
                "imgId": $("#spuImgId1").html(),
                "imgSort": $("#spuImgSort1").val(),
                "imgUrl": $("#spuImgUrl1").html().split("?")[0]
            })
        }
        if($("#spuImg2").children().length != 0){
            spuImgs.push( {
                "imgId": $("#spuImgId2").html(),
                "imgSort": $("#spuImgSort2").val(),
                "imgUrl": $("#spuImgUrl2").html().split("?")[0]
            })
        }
        if($("#spuImg3").children().length != 0){
            spuImgs.push( {
                "imgId": $("#spuImgId3").html(),
                "imgSort": $("#spuImgSort3").val(),
                "imgUrl": $("#spuImgUrl3").html().split("?")[0]
            })
        }
        if($("#spuImg4").children().length != 0){
            spuImgs.push( {
                "imgId": $("#spuImgId4").html(),
                "imgSort": $("#spuImgSort4").val(),
                "imgUrl": $("#spuImgUrl4").html().split("?")[0]
            })
        }
        if($("#spuImg5").children().length != 0){
            spuImgs.push( {
                "imgId": $("#spuImgId5").html(),
                "imgSort": $("#spuImgSort5").val(),
                "imgUrl": $("#spuImgUrl5").html().split("?")[0]
            })
        }
        var aliasArr = [];
        var another_name = document.querySelectorAll(".another_name");
        for(var i=0;i<another_name.length;i++){
            if(another_name[i].value !== ""){
                aliasArr.push(another_name[i].value);
            }
        }
        var JsonObject =JSON.parse(decodeURIComponent(web.readCookie("loginData")));
        $.ajax({
            contentType:'application/json',
            url: 'https://'+ window.location.host +'/api/admin/aproduct/product/saveSpuDetail',
            cache: false,  //禁用缓存
            type: "POST",
            data: JSON.stringify({
                "spuName": $("#goodsName").val(),
                "subTitile": $("#subtitile").val(),
                "alias": aliasArr,
                "brandId": $("#brandId").html(),
                "categoryid": threeCategoryId,
                "imgList": spuImgs,
                "detail": UE.getEditor('editor').getContent(),
                "creationBy":JsonObject.user.user_ID,
            }),
            success: function (data) {
                if(data.errorCode == 0){
                    layer.msg("添加成功",{icon: 6,time:1000},function () {
                        var index =  parent.location.reload();
                        parent.layer.close(index);
                    });
                }
            }
        });
    }
}